home *** CD-ROM | disk | FTP | other *** search
/ Enter 2001 August / EnterCD8.iso / Internet / HTTrack Website Copier / httrack.exe / {app} / src / configure next >
Encoding:
Text File  |  2001-05-09  |  9.0 KB  |  354 lines

  1. #!/bin/sh
  2. # No, this isn't generated by autoconf
  3. # Some parts are inspired by autoconf (Free Software Foundation), however
  4. # And the idea is slightly the same
  5.  
  6. # Usage:
  7. # './configure' and then 'make' and 'make install', or
  8. # './configure --make --install'
  9.  
  10. SHELL=/bin/sh
  11.  
  12. ac_prev=
  13. for ac_option
  14. do
  15.   # If the previous option needs an argument, assign it.
  16.   if test -n "$ac_prev"; then
  17.     eval "$ac_prev=\$ac_option"
  18.     ac_prev=
  19.     continue
  20.   fi
  21.  
  22.   case "$ac_option" in
  23.     -*=*) ac_optarg=`echo "$ac_option" | sed 's/[-_a-zA-Z0-9]*=//'` ;;
  24.     *) ac_optarg= ;;
  25.   esac
  26.  
  27.   case "$ac_option" in
  28.  
  29.   --pthread | --thread)     THREADS=1   ;;
  30.   --nopthread | --nothread) THREADS=0   ;;
  31.  
  32.   --longlong)               LONGLONG=1  ;;
  33.   --nolonglong)             LONGLONG=0  ;;
  34.  
  35.   --inaddrt)                NODECLINADDRT=0 ;;
  36.   --noinaddrt)              NODECLINADDRT=1 ;;
  37.  
  38.   --useuid)                 NOUID=0     ;;
  39.   --nouseuid)               NOUID=1     ;;
  40.  
  41.   --useftime)               NOFTIME=0   ;;
  42.   --nouseftime)             NOFTIME=1   ;;
  43.  
  44.   --system=*)               SYSTEMTYPE="$ac_optarg" ;;
  45.   --system)                 ac_prev=SYSTEMTYPE ;;
  46.  
  47.   --debug)                  OTYPE="-O0 -g3" ;;
  48.  
  49.   --make)                   DOMAKE=1    ;;
  50.   --install)                DOINSTALL=1 ;;
  51.   --bininstall)             DOINSTALL=1
  52.                             NODOCINSTALL=1
  53.                             ;;
  54.   --docinstall)             DOINSTALL=1
  55.                             DOCINSTALL=1
  56.                             ;;
  57.   --cls)
  58.     strip_cr *.c *.h
  59.     rm -f httrack 2>/dev/null
  60.     chmod 644 *.h *.c
  61.     chmod u+w *
  62.     exit    
  63.     ;;
  64.   -bindir | --bindir | --bindi | --bind | --bin | --bi)
  65.     ac_prev=bindir ;;
  66.   -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*)
  67.     bindir="$ac_optarg" ;;
  68.  
  69.   --help)
  70.     cat <<EOF
  71. --nopthread  : do not use threads (pthread.h)
  72. --pthread    : do     use threads (pthread.h)
  73. --nolonglong : do not use 64-bit int
  74. --longlong   : do     use 64-bit int
  75. --noinaddrt  : do not redeclare in_addr_t
  76. --inaddrt    : do     redeclare in_addr_t
  77. --nouseuid   : do not use setuid()/setgid()
  78. --useuid     : do     use setuid()/setgid()
  79. --nouseftime : do not use ftime()
  80. --useftime   : do     use ftime()
  81. --system=<type> : override system type (uname) (types: 'Default','Linux','SunOS','AIX')
  82. --make       : 'make' after configure
  83. --install    : 'make install' after configure
  84. --bininstall : 'make bininstall' after configure
  85. --debug      : add debug information (for gdb)
  86. EOF
  87.   exit
  88.   ;;
  89.  
  90.   *) echo "Unrecognized option: $ac_option" 
  91.      exit 
  92.      ;;
  93.  
  94.   esac
  95.  
  96. done
  97.  
  98. echo "Welcome to HTTrack Website Copier!"
  99. echo "Type in ./configure --help for more details"
  100. echo "If this script fails, you can enter supplemental options through '--option=value'"
  101. echo "or enter in manual make, through 'make help'"
  102. echo ""
  103.  
  104. if cp -f Makefile.in Makefile; then
  105.  
  106. SEDEXEC=
  107.  
  108. # System (OS) type?
  109. printf "Checking for OS type.. "
  110. if test -z "$SYSTEMTYPE"; then
  111.     SYSTEMTYPE="`uname`"
  112. fi
  113. case "$SYSTEMTYPE" in 
  114.     SunOS) printf "SunOS/Solaris\n"; 
  115.                PLATFORM=0
  116.                SOLSOCK=1
  117.                ;;
  118.     AIX)   printf "AIX\n";           PLATFORM=2 ;;
  119.     *)     printf "Linux type\n";    PLATFORM=3 ;;
  120. esac
  121.  
  122. WTYPE="-Wall -Wcast-align -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wpointer-arith -Wnested-externs"
  123.  
  124. if test -z "$OTYPE"; then
  125.     OTYPE="-O3"
  126. fi
  127.  
  128. # Binaries location
  129. if test -z "$BINPATH"; then
  130. printf "Checking for bin directory.. "
  131. if test -d "/usr/bin"; then
  132.     BINPATH="/usr/bin"
  133. else
  134.     BINPATH="/bin"
  135. fi
  136. printf "$BINPATH\n"
  137. else
  138.     echo "Overriding BINPATH=$BINPATH"
  139. fi
  140.  
  141. # Prefix location
  142. if test -z "$PREFIX"; then
  143.     printf "Checking for usr directory.. "
  144.     PREFIX="/usr"
  145.     printf "$PREFIX\n"
  146. else
  147.     echo "Overriding PREFIX=$PREFIX"
  148. fi
  149.  
  150. # 64-bit (long long) cause some troubles to some processors
  151. # because some alignements aren't properly defined
  152. # we only accept 64-bit on tested processors here
  153. if test -z "$LONGLONG"; then
  154. printf "Checking for long long.. "
  155. LONGLONG=
  156. if grep "long long" /usr/include/sys/types.h >/dev/null; then
  157. if uname -a|grep -E ' i[3-9]86 ' >/dev/null; then
  158.     LONGLONG=1
  159. fi
  160. fi
  161. if test -n "$LONGLONG"; then
  162.     printf "supported\n"
  163. else
  164.     printf "not tested/supported. Use --LONGLONG=1 to override\n"
  165. fi
  166. else
  167.     echo "Overriding LONGLONG=$LONGLONG"
  168. fi
  169.  
  170. # Do we not have to redeclare in_addr_t ?
  171. # Sometimes this type is defined, or not..
  172. if test -z "$NODECLINADDRT"; then
  173. printf "Checking for in_addr_t declaration in /usr/include/arpa/inet.h.. "
  174. if grep "in_addr_t" /usr/include/arpa/inet.h >/dev/null; then
  175.     printf "found, do not redeclare\n"
  176.     NODECLINADDRT=1
  177. else
  178.     printf "not found, declaring\n"
  179.     NODECLINADDRT=
  180. fi
  181. else
  182.     echo "Overriding NODECLINADDRT=$NODECLINADDRT"
  183. fi
  184.  
  185. # Sometimes, pthread.h doesn't exists on some systems
  186. # This is sad, because it speeds up some useful things, like DNS or ftp
  187. if test -z "$THREADS"; then
  188. printf "Checking for /usr/include/pthread.h.. "
  189. if test -f "/usr/include/pthread.h"; then
  190. if test -f "/usr/lib/libpthread.so"; then
  191.     printf "found\n"
  192.     THREADS=1
  193. else
  194.     printf "library not found (too bad), no threads will be available\n"
  195.     THREADS=
  196. fi
  197. else
  198.     printf "not found, no threads will be available\n"
  199.     THREADS=
  200. fi
  201. else
  202.     echo "Overriding THREADS=$THREADS"
  203. fi
  204.  
  205. # Sometimes, setuid and setgid can't be used (missing pwd.h and unistd.h ?!)
  206. if test -z "$NOUID"; then
  207. NOUID=1
  208. printf "Checking for /usr/include/pwd.h and /usr/include/unistd.h.. "
  209. if test -f "/usr/include/pwd.h"; then
  210. if test -f "/usr/include/unistd.h"; then
  211.     NOUID=
  212. fi
  213. fi
  214. if test -z "$NOUID"; then
  215.     printf "found\n"
  216. else
  217.     printf "not found, not using setuid() and setgid()\n"
  218. fi
  219. else
  220.     echo "Overriding NOUID=$NOUID"
  221. fi
  222.  
  223. # Sometimes, ftime can't be used (missing declaration...)
  224. if test -z "$NOFTIME"; then
  225. NOFTIME=1
  226. printf "Checking for ftime in /usr/include/sys/timeb.h.. "
  227. if grep "extern int ftime" /usr/include/sys/timeb.h >/dev/null; then
  228.     NOFTIME=
  229. fi
  230. if test -z "$NOFTIME"; then
  231.     printf "found\n"
  232. else
  233.     printf "not found (too bad), not using ftime()\n"
  234. fi
  235. else
  236.     echo "Overriding NOFTIME=$NOFTIME"
  237. fi
  238.  
  239. # Test variables
  240. if test "$NOUID" = 1; then
  241.     SEDEXEC="$SEDEXEC | sed -e 's/__DEFINEUID__/HTS_DO_NOT_USE_UID/'"
  242. fi
  243. if test "$NOFTIME" = 1; then
  244.     SEDEXEC="$SEDEXEC | sed -e 's/__DEFINEFTI__/HTS_DO_NOT_USE_FTIME/'"
  245. fi
  246. if test "$NODECLINADDRT" = 1; then
  247.     SEDEXEC="$SEDEXEC | sed -e 's/__DEFINEINA__/HTS_DO_NOT_REDEFINE_in_addr_t/'"
  248. fi
  249. if test "$THREADS" = 1; then
  250.     SEDEXEC="$SEDEXEC | sed -e \"s/__CFLAGS__/$OTYPE $WTYPE -D_REENTRANT/g\""
  251.     SEDEXEC="$SEDEXEC | sed -e 's/__LFLAGS__/-lpthread/g'"
  252. else
  253.     SEDEXEC="$SEDEXEC | sed -e 's/__DEFINEPTH__/HTS_DO_NOT_USE_PTHREAD/'"
  254.     SEDEXEC="$SEDEXEC | sed -e \"s/__CFLAGS__/$OTYPE $WTYPE/g\""
  255.     SEDEXEC="$SEDEXEC | sed -e 's/__LFLAGS__//g'"
  256. fi
  257. if test "$SOLSOCK" = 1; then
  258.     SEDEXEC="$SEDEXEC | sed -e 's/__LFLAGS2__/-lnsl -lsocket/g'"
  259. else
  260.     SEDEXEC="$SEDEXEC | sed -e 's/__LFLAGS2__//g'"
  261. fi
  262. if test ! "$LONGLONG" = 1; then
  263.     SEDEXEC="$SEDEXEC | sed -e 's/__DEFINE64B__/HTS_NO_64_BIT/'"
  264. fi
  265. SEDEXEC="$SEDEXEC | sed -e \"s/__PLATFORM__/$PLATFORM/g\""
  266. SEDEXEC="$SEDEXEC | sed -e 's/#__AUTONAME__/AUTONAME  = auto/'"
  267. SEDEXEC="$SEDEXEC | sed -e 's/#define __DEFINE.*__//g'"
  268. TMP=`echo $BINPATH | sed -e 's/\\//\\\\\\//g'` 
  269. SEDEXEC="$SEDEXEC | sed -e \"s/#__BINPATH__/BINPATH = $TMP/g\""
  270. TMP=`echo $PREFIX | sed -e 's/\\//\\\\\\//g'`
  271. SEDEXEC="$SEDEXEC | sed -e \"s/#__PREFIX__/PREFIX = $TMP/g\""
  272. SEDEXEC="$SEDEXEC | sed -e \"s/__DEFINEPRE__/$TMP/g\""
  273.  
  274. # Search for gmake
  275. printf "Checking for make.. "
  276. MAKEPATH=
  277. if test -f "/usr/bin/gmake"; then
  278. MAKEPATH=/usr/bin/gmake
  279. else
  280. if test -f "/bin/gmake"; then
  281. MAKEPATH=/bin/gmake
  282. else
  283. if test -f "/usr/local/bin/gmake"; then
  284. MAKEPATH=/usr/local/bin/gmake
  285. fi
  286. fi
  287. fi
  288. if test -n "$MAKEPATH"; then
  289. printf "found $MAKEPATH\n"
  290. else
  291. MAKEPATH=make
  292. printf "not found, assume make will work\n"
  293. fi
  294.  
  295. # Sed strip_cr
  296. printf "Checking for perl.. "
  297. PERLPATH=
  298. cp -f strip_cr.in strip_cr
  299. if test -f "/usr/bin/perl"; then
  300. PERLPATH=/usr/bin/perl
  301. else
  302. if test -f "/bin/perl"; then
  303. PERLPATH=/bin/perl
  304. else
  305. if test -f "/usr/local/bin/perl"; then
  306. PERLPATH=/usr/local/bin/perl
  307. fi
  308. fi
  309. fi
  310. if test -n "$PERLPATH"; then
  311. printf "found $PERLPATH\nEnsuring that *.c/*.h source files don't contains CR (^M).. "
  312. TMP=`echo $PERLPATH | sed -e 's/\\//\\\\\\//g'` 
  313. cat strip_cr | sed -e "s/__PERL__/$TMP/" >  __tmp; mv __tmp strip_cr
  314. chmod 700 strip_cr
  315. ./strip_cr *.c *.h
  316. printf "done\n"
  317. fi
  318.  
  319. # Sed all __VARS__
  320. CMD="cat Makefile $SEDEXEC > __tmp; mv __tmp Makefile"
  321. echo "Command: $CMD"
  322. if eval $CMD; then
  323.  
  324. echo ""
  325. echo "Makefile created!"
  326. echo "Type in '$MAKEPATH' to build and '$MAKEPATH install' to install"
  327.  
  328. if test -n "$DOMAKE"; then
  329.     echo "Making.."
  330.     eval $MAKEPATH clean
  331.     eval $MAKEPATH
  332. fi
  333. if test -n "$DOINSTALL"; then
  334.     if test -n "$NODOCINSTALL"; then
  335.       echo "Installing binary.."
  336.       eval $MAKEPATH bininstall
  337.     elif test -n "$DOCINSTALL"; then
  338.       echo "Installing docs.."
  339.       eval $MAKEPATH docinstall
  340.     else
  341.       echo "Installing.."
  342.       eval $MAKEPATH install
  343.     fi
  344. fi
  345.  
  346. else
  347.     echo "Error while seding Makefile.."
  348. fi
  349.  
  350. else
  351.     echo "Error copying Makefile.in -> Makefile.. giving up"
  352. fi
  353.  
  354.